﻿
@using Treca.Business.Base_SysManage;
@using Treca.Quartz.Entity;
@using Treca.Util;
@using EFCore.Sharding;
@inherits DependencyViewPage 
@using System.Data;
@using Microsoft.AspNetCore.Http;
@{
    Layout = "~/Views/Shared/_Layout_List.cshtml";
    var returnkey = (string)this.ViewData["returnkey"];
}

   
<div class="fx-content">
      <div id = "toobar" >   
           <div class="btn-group btn-group-sm">
 
            <button type = "button" class="btn btn-primary" aria-label="Right Align" onclick="javascript: location.reload();">
                <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
                @TranslateService.GetTranslate("","System_Flash","刷新")
            </button>
        </div>
    </div>
</div>
<div class="fx-wrapper">
      <form class="form-inline" id="searchForm">
        <div class="form-group">
                <label>查询类别</label>
                <select class="selectpicker" id="condition" name="condition" data-style="btn-info btn-sm" data-width="100px">
                    <option value="">@TranslateService.GetTranslate("","System_Select","选择")</option>
                    
                         <option value="JobClass">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobClass","任务类")</option>
                         <option value="JobGroup">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobGroup","任务组")</option>
                         <option value="JobName">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobName","任务名")</option>
                         <option value="JobDesc">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobDesc","任务描述")</option>
                         <option value="RunStatus">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_RunStatus","运行状态")</option>
                         <option value="CromExpress">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_CromExpress","Cron表达式")</option>
                         <option value="Remark">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_Remark","备注")</option>
                         <option value="StatusFlag">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_StatusFlag","使用状态")</option>
                         <option value="CreateOperator">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_CreateOperator","创建人")</option>
                         <option value="ModifyOperator">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_ModifyOperator","修改人")</option>
                         <option value="IsDelete">@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_IsDelete","删除标记")</option>
                </select>
                <input type="text" class="form-control input-sm" id="keyword" name="keyword" placeholder='@TranslateService.GetTranslate("","System_PleaseEnterKeywords","请输入关键字")'>
  </div>

        <div class="form-group">
            <button type = "button" class="btn btn-primary" onclick="javascript: $('#dataTable').bootstrapTable('refresh', { silent: true,pageNumber:1 });">
                <i class="glyphicon glyphicon-search"></i>
                查询
            </button>

 
        </div>
    </form>
</div> 
    <div class="fx-wrapper">
        <table id="dataTable" class="table-bordered"></table>
    </div>

<script>
    var $table = $('#dataTable');
    $(function () {
        initTable();
    });

    //初始化表格
    function initTable() {
        $table.bootstrapTable({
            url: '/Quartz/base_schedulesinfo/GetDataListBySearchInfo',
            idField: 'Id',
            method: 'post',
            contentType: 'application/json',
            queryParamsType: '',
            clickToSelect: false,
            pagination: true,
            sidePagination: "server",
            pageNumber: 1,
            pageSize: 30,
            pageList: [10, 30, 60, 100],
            onCheck: function (row) {
                window.chekcCode = row['@returnkey.Split(',')[0]'];
                window.chekcName = row['@returnkey.Split(',')[1]'];
            },
            onUncheck: function (row) {  window.chekcName = '' ; window.chekcCode = '' ;},
            columns: [
                { title: 'ck', field: 'ck', checkbox: true, width: '3%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobClass","任务类")', field: 'JobClass', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobGroup","任务组")', field: 'JobGroup', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobName","任务名")', field: 'JobName', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_JobDesc","任务描述")', field: 'JobDesc', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_RunStatus","运行状态")', field: 'RunStatus', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_CromExpress","Cron表达式")', field: 'CromExpress', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_StarRunTime","开始运行时间")', field: 'StarRunTime', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_EndRunTime","结束运行时间")', field: 'EndRunTime', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_PreviousRunTime","上次运行时间")', field: 'PreviousRunTime', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_NextRunTime","下次运行时间")', field: 'NextRunTime', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_Remark","备注")', field: 'Remark', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_CreateDate","创建日期")', field: 'CreateDate', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_CreateOperator","创建人")', field: 'CreateOperator', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_ModifyDate","修改日期")', field: 'ModifyDate', width: '5%' },
                    { title: '@TranslateService.GetTranslate("","Quartz_base_schedulesinfo_ModifyOperator","修改人")', field: 'ModifyOperator', width: '5%' },             
                 {title: '使用状态', formatter: function (value, row, index) {
                        if (row.StatusFlag == '1') {
                            return '<span class="badge badge-primary">@TranslateService.GetTranslate("","System_Approve_Flag","已审核")</span>';
                        } if (row.StatusFlag == '2') {
                                return '<span class="badge badge-primary">@TranslateService.GetTranslate("","System_Reverse_Flag","反审核")</span>';
                        }if (row.StatusFlag == '0') {
                                return '<span class="badge badge-primary">@TranslateService.GetTranslate("","System_UnApprove_Flag","未审核")</span>';
                        }  
                    }}
            ],onPreBody: function (data) {
                for(var i=0,l=data.length;i<l;i++){
                    for(var key in data[i]){
                        if (data[i][key + "__Name"] != null) {
                            data[i][key] = data[i][key + "__Name"];
                        }
                    }
                }
            },
            queryParams: function (params) {
                var condition = $("#condition").val();
                var keyword = $("#keyword").val();
                var searchParams = [];
                if (condition != '' && condition != null && keyword != '' && keyword!=null)
                {
                    var searchinfo = new SearchInfo();
                    searchinfo.FiledName = condition;
                    searchinfo.Value = keyword;
                    searchParams.push(searchinfo);
                }
                var values = $('#searchForm').getValues();
                    for (var item in values)
                {
                    if (item == 'condition' || item == 'keyword' || values[item] == '' || values[item]== null) continue;
                    var Operate = $('#searchForm').find('#' + item).attr('Operate');
                    if (Operate == null) Operate = '包含';
                    var searchinfo = new SearchInfo();
                    searchinfo.FiledName = item;
                    searchinfo.Value = values[item];
                    searchinfo.Operate = Operate;
                    searchParams.push(searchinfo);
                }
                return { pagination:params,searchInfos: searchParams };
            }
        });
    }



</script>
